package com.sun.impls.users;

import cn.dev33.satoken.stp.StpInterface;
import cn.dev33.satoken.stp.StpUtil;
import com.sun.utils.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;


import java.util.List;

/**
 * MP自动填充Handler
 *
 * @Author sun
 * @CreateTime 2025/9/3 00:00
 */
@Component
public class StpInterfaceImpl implements StpInterface {
    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        String key = Constant.REDIS_ROLE_PERMISSION_PREFIX + loginId.toString();
        List<String> permissions = (List<String>) redisTemplate.opsForValue().get(key);
        return permissions;
    }

    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        List<String> roles = (List<String>) StpUtil.getExtra("roles");
        return roles;
    }
}
